package com.wondersgroup.fjzlpt.gateway.config;

import com.quick.framework.boot.pidLog.PIDListener;
import com.wondersgroup.fjzlpt.gateway.filtes.ErrorFilter;
import com.wondersgroup.fjzlpt.gateway.filtes.QuickAuthClientFilter;
import com.wondersgroup.fjzlpt.gateway.filtes.QuickCertClientFilter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by lion on 2017/6/15.
 */
@Configuration
@ConfigurationProperties(prefix = "common")
public class FilterConfig {

    @Bean
    public PIDListener getPIDListener(){
        return new PIDListener();
    }

    @Value(value = "${common.domainKey}")
    String domainKey;
    @Value(value = "${common.loginUrl}")
    String loginUrl;

    List<String> ignoreParrent = new ArrayList<>();

    List<String> certParrent = new ArrayList<>();

    @Bean
    public QuickCertClientFilter getQuickCertClientFilter(){
        return new QuickCertClientFilter(domainKey, loginUrl, ignoreParrent, certParrent);
    }

    @Bean
    public QuickAuthClientFilter getQuickAuthClientFilter(){
        return new QuickAuthClientFilter();
    }

    @Bean
    public ErrorFilter getErrorFilter(){
        return new ErrorFilter();
    }

    public void setIgnoreParrent(List<String> ignoreParrent) {
        this.ignoreParrent = ignoreParrent;
    }

    public List<String> getIgnoreParrent() {
        return ignoreParrent;
    }

    public List<String> getCertParrent() {
        return certParrent;
    }
    public void setCertParrent(List<String> certParrent) {
        this.certParrent = certParrent;
    }
}
